package com.hq.service.impl;

import com.hq.pojo.User;
import com.hq.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;

public class UserServiceImpl implements UserService {
    @Override
    public User login(User user) {
        try{
            UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(),user.getPassword());
            Subject subject = SecurityUtils.getSubject();
            subject.login(token);
            return user;
        }catch (Exception e){
            return null;
        }

    }
}
